<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script>
        let promise = new Promise((resolve, reject) => {
            console.log('创建Promise对象....')
            resolve('success')
            // throw new Error('error message')
        })

        promise.then(
            function(value) {
                console.log('promise执行成功的结果为' + value)
            }
            // then里面的第二个reject函数可以省略不写，当Promise对象的状态为
            // rejected时会直接被catch中的函数接收到
        ).catch(
            function(value) {
                console.log('报错了' + value)
            }
        )
    </script>
</head>
<body>
</body>
</html>